using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Markup;
using Common;
using Common.Enum;
using Controls;
using SSettings;

namespace SettingsView
{
	public partial class HotlidTemperatureSettingWindow : Window, IComponentConnector
	{
		private ObservableCollection<TypeTemperature> _HotlidTemperatures = new ObservableCollection<TypeTemperature>();

		public ObservableCollection<TypeTemperature> HotlidTemperatures
		{
			get
			{
				return _HotlidTemperatures;
			}
			set
			{
				if (_HotlidTemperatures != value)
				{
					_HotlidTemperatures = value;
				}
			}
		}

		public HotlidTemperatureSettingWindow()
		{
			InitializeComponent();
			SetViewControl();
		}

		private void btnOK_Click(object sender, RoutedEventArgs e)
		{
			base.DialogResult = true;
			Close();
		}

		private void SetViewControl()
		{
			List<KeyValuePair> hotlidTemperatures = ConfigSettings.GetInstance().BasicSetting.HotlidTemperatures;
			foreach (KeyValuePair item in hotlidTemperatures)
			{
				HotlidTemperatures.Add(new TypeTemperature
				{
					Type = (EProjectType)item.Key,
					Temperature = (int)item.Value,
					visbile = (ConfigReader.GetInstance().GetProjectTypeFromIni((EProjectType)item.Key) == 1)
				});
			}
			int num = 80;
			foreach (TypeTemperature hotlidTemperature in HotlidTemperatures)
			{
				if (hotlidTemperature.visbile)
				{
					StackPanel stackPanel = new StackPanel();
					stackPanel.HorizontalAlignment = HorizontalAlignment.Left;
					stackPanel.VerticalAlignment = VerticalAlignment.Top;
					stackPanel.Height = 36.0;
					stackPanel.Orientation = Orientation.Horizontal;
					num += 36;
					TextBlock textBlock = new TextBlock();
					textBlock.Height = 23.0;
					textBlock.Width = 190.0;
					textBlock.HorizontalAlignment = HorizontalAlignment.Left;
					textBlock.VerticalAlignment = VerticalAlignment.Center;
					StringBuilder stringBuilder = new StringBuilder();
					stringBuilder.Append(EnumManagement.GetProjectTypeName(hotlidTemperature.Type));
					stringBuilder.Append(Utility.GetMessage("hotbonnet_temperature"));
					stringBuilder.Append(Utility.GetMessage("Colon"));
					textBlock.Text = stringBuilder.ToString();
					textBlock.Margin = new Thickness(8.0, 0.0, 0.0, 0.0);
					NumericSpan numericSpan = new NumericSpan();
					numericSpan.MinValue = 3.0;
					numericSpan.MaxValue = 105.0;
					numericSpan.Width = 186.0;
					numericSpan.Height = 26.0;
					numericSpan.Margin = new Thickness(16.0, 2.0, 0.0, 0.0);
					numericSpan.HorizontalAlignment = HorizontalAlignment.Left;
					numericSpan.VerticalAlignment = VerticalAlignment.Center;
					Binding binding = new Binding();
					binding.Path = new PropertyPath("Temperature");
					binding.Source = hotlidTemperature;
					binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
					binding.NotifyOnSourceUpdated = true;
					binding.Mode = BindingMode.TwoWay;
					numericSpan.SetBinding(NumericSpan.ValueProperty, binding);
					stackPanel.Children.Add(textBlock);
					stackPanel.Children.Add(numericSpan);
					MainPanel.Children.Add(stackPanel);
				}
			}
			base.Height = num;
		}
	}
}
